class classproperty(object):
    def __init__(self, fget = None, doc = None):
        self.__get = fget
        self.__doc__ = doc

    def __get__(self, inst, type):
        if self.__get is None:
            raise AttributeError, 'cannot read attribute'
        return self.__get(type)

def _classproperty_test():
    class Base(object):
        @classproperty
        def two(cls):
            return cls.one + cls.one

    class Derived(Base):
        one = 1

    assert Derived.two == 2
    assert Derived().two == 2

class staticproperty(object):
    def __init__(self, fget = None, doc = None):
        self.__get = fget
        self.__doc__ = doc

    def __get__(self, inst, type):
        if self.__get is None:
            raise AttributeError, 'cannot read attribute'
        return self.__get()

def _staticproperty_test():
    class Tester(object):
        @staticproperty
        def one():
            return 1

    assert Tester.one == 1
    assert Tester().one == 1

if __name__ == '__main__':
    _classproperty_test()
    _staticproperty_test()
